﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using SYcwpb.Helpers;
using System.Collections.ObjectModel;
using SYcwpb.Models;
using SYcwpb.Commands;
using System.Windows.Input;
using SYcwpb.Access;
using System.Windows.Threading;
using System.Threading;
using SYcwpb.Views;
using System.Windows;
using System.Collections.Specialized;
using SYcwpb.ViewModels.DataProvider;

namespace SYcwpb.ViewModels.DataProvider
{
    class AttendanceDataProvider
    {
        private DriverAttendanceOrderAdjustAccess _access = new DriverAttendanceOrderAdjustAccess();

        public AttendanceObjects GetAttendances()
        {
            AttendanceObjects _attendances = new AttendanceObjects();
            ObservableCollection<DriverAttendanceOrderAdjustModel> driverModels = _access.GetDriversByGroup(null);
            foreach (DriverAttendanceOrderAdjustModel model in driverModels)
            {
                _attendances.Add(new AttendanceObject(model));
            }
            _attendances.itemEndEdit += new ItemEndEditEventHandler(attendances_itemEndEdit);
            _attendances.CollectionChanged += new NotifyCollectionChangedEventHandler(attendances_CollectionChanged);

            return _attendances;
        }

        void attendances_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            //throw new NotImplementedException();
        }

        void attendances_itemEndEdit(System.ComponentModel.IEditableObject sender)
        {
            //throw new NotImplementedException();
            AttendanceObject item = sender as AttendanceObject;

            MessageBoxHelper.ShowTips(string.Format("ID == {0}", item.ID));
        }
    }
}
